package com.atguigu.security.custom;

import com.atguigu.auth.utils.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author 赵星
 * @version 1.0
 * @Date 2023/11/8 14:45
 */
@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {//加密密码
        return MD5.encrypt(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {//密码校验
        return encodedPassword.equals(MD5.encrypt(rawPassword.toString()));
    }
}
